<?php

use think\facade\Route;
use think\facade\Request;

$version = Request::header('version', 'v1');#接口版本
Route::group('', function () use ($version) {
    // 登录
    Route::group('site', function () use ($version) {
        Route::post('login', "backend/{$version}.Site/login");
    });

    // 后台用户管理
    Route::group('backendMember', function () use ($version) {
        Route::get('read', "backend/{$version}.BackendMember/read");
        Route::get('create', "backend/{$version}.BackendMember/create");
        Route::post('save', "backend/{$version}.BackendMember/save");
        Route::post('update', "backend/{$version}.BackendMember/update");
        Route::get('edit', "backend/{$version}.BackendMember/edit");
        Route::delete('delete', "backend/{$version}.BackendMember/delete");
        Route::get(':id', "backend/{$version}.BackendMember/index");
        //  获取后台角色信息
        Route::get('get-role', "backend/{$version}.BackendMember/getrole");
        Route::get('member-info', "backend/{$version}.BackendMember/memberInfo");
        Route::get('login-out', "backend/{$version}.BackendMember/loginOut");
        //  清除缓存
        Route::get('clear-cache', "backend/{$version}.BackendMember/clearcache");
    })->middleware('checkLogin');

    // 会员管理
    Route::group('member', function () use ($version) {
        Route::get('index', "backend/{$version}.Member/index");
        Route::post('create', "backend/{$version}.Member/create");
        Route::put('update', "backend/{$version}.Member/update");
        Route::delete('delete', "backend/{$version}.Member/delete");
    })->middleware('checkLogin');

    //节点管理
    Route::group('permission', function () use ($version) {
        Route::get('index', "backend/{$version}.BackendPermission/index");
        Route::get('create', "backend/{$version}.BackendPermission/create");
        Route::post('save', "backend/{$version}.BackendPermission/save");
        Route::post('update', "backend/{$version}.BackendPermission/update");
        Route::get('edit', "backend/{$version}.BackendPermission/edit");
        Route::delete('delete', "backend/{$version}.BackendPermission/delete");
    })->middleware('checkLogin');

    //角色管理
    Route::group('role', function () use ($version) {
        Route::get('index', "backend/{$version}.BackendRole/index");
        Route::post('save', "backend/{$version}.BackendRole/save");
        Route::post('update', "backend/{$version}.BackendRole/update");
        Route::get('edit', "backend/{$version}.BackendRole/edit");
        Route::delete('delete', "backend/{$version}.BackendRole/delete");
    })->middleware('checkLogin');

    //角色权限
    Route::group('rolePermission', function () use ($version) {
        Route::get('create', "backend/{$version}.BackendRolePermission/create");
        Route::get('index', "backend/{$version}.BackendRolePermission/index");
        Route::post('save', "backend/{$version}.BackendRolePermission/save");
        Route::post('update', "backend/{$version}.BackendRolePermission/update");
        Route::get('edit', "backend/{$version}.BackendRolePermission/edit");
        Route::delete('delete', "backend/{$version}.BackendRolePermission/delete");
    })->middleware('checkLogin');

    //产品分类
    Route::group('productCate', function () use ($version) {
        Route::get('index', "backend/{$version}.ProductCate/index");
        Route::post('save', "backend/{$version}.ProductCate/save");
        Route::post('update', "backend/{$version}.ProductCate/update");
        Route::get('edit', "backend/{$version}.ProductCate/edit");
        Route::delete('delete', "backend/{$version}.ProductCate/delete");
    })->middleware('checkLogin');

    //产品
    Route::group('product', function () use ($version) {
        Route::get('index', "backend/{$version}.Product/index");
        Route::post('save', "backend/{$version}.Product/save");
        Route::post('update', "backend/{$version}.Product/update");
        Route::get('edit', "backend/{$version}.Product/edit");
        Route::delete('delete', "backend/{$version}.Product/delete");
    })->middleware('checkLogin');

    //产品属性
    Route::group('attribute', function () use ($version) {
        Route::get('index', "backend/{$version}.Attribute/index");
        Route::post('save', "backend/{$version}.Attribute/save");
        Route::post('update', "backend/{$version}.Attribute/update");
        Route::get('edit', "backend/{$version}.Attribute/edit");
        Route::delete('delete', "backend/{$version}.Attribute/delete");
    })->middleware('checkLogin');

    //产品属性值
    Route::group('value', function () use ($version) {
        Route::get('index', "backend/{$version}.Value/index");
        Route::post('save', "backend/{$version}.Value/save");
        Route::post('update', "backend/{$version}.Value/update");
        Route::get('edit', "backend/{$version}.Value/edit");
        Route::delete('delete', "backend/{$version}.Value/delete");
    })->middleware('checkLogin');

    //产品系列
    Route::group('series', function () use ($version) {
        Route::get('index', "backend/{$version}.Series/index");
        Route::post('save', "backend/{$version}.Series/save");
        Route::post('update', "backend/{$version}.Series/update");
        Route::get('edit', "backend/{$version}.Series/edit");
        Route::delete('delete', "backend/{$version}.Series/delete");
    })->middleware('checkLogin');

    //轮播图管理
    Route::group('banner', function () use ($version) {
        Route::get('index', "backend/{$version}.Banner/index");
        Route::post('create', "backend/{$version}.Banner/create");
        Route::post('update', "backend/{$version}.Banner/update");
        Route::delete('delete', "backend/{$version}.Banner/delete");
    });

    //新闻资讯管理
    Route::group('newsInfo', function () use ($version) {
        Route::get('index', "backend/{$version}.newsInfo/index");
        Route::post('create', "backend/{$version}.newsInfo/create");
        Route::post('update', "backend/{$version}.newsInfo/update");
        Route::delete('delete', "backend/{$version}.newsInfo/delete");
    });

    //发展历程管理
    Route::group('develop', function () use ($version) {
        Route::get('index', "backend/{$version}.develop/index");
        Route::post('create', "backend/{$version}.develop/create");
        Route::post('update', "backend/{$version}.develop/update");
        Route::delete('delete', "backend/{$version}.develop/delete");
    });

    //视频管理
    Route::group('video', function () use ($version) {
        Route::get('index', "backend/{$version}.video/index");
        Route::post('create', "backend/{$version}.video/create");
        Route::post('update', "backend/{$version}.video/update");
        Route::delete('delete', "backend/{$version}.video/delete");
    });

    //轮播详情管理
    Route::group('bannerDetails', function () use ($version) {
        Route::get('index', "backend/{$version}.bannerDetails/index");
        Route::post('create', "backend/{$version}.bannerDetails/create");
        Route::post('update', "backend/{$version}.bannerDetails/update");
        Route::delete('delete', "backend/{$version}.bannerDetails/delete");
    });

    //轮播详情管理
    Route::group('deduceWonderful', function () use ($version) {
        Route::get('index', "backend/{$version}.deduceWonderful/index");
        Route::post('create', "backend/{$version}.deduceWonderful/create");
        Route::post('update', "backend/{$version}.deduceWonderful/update");
        Route::delete('delete', "backend/{$version}.deduceWonderful/delete");
    });

    //买家故事管理
    Route::group('BuyersStory', function () use ($version) {
        Route::get('index', "backend/{$version}.BuyersStory/index");
        Route::post('create', "backend/{$version}.BuyersStory/create");
        Route::post('update', "backend/{$version}.BuyersStory/update");
        Route::delete('delete', "backend/{$version}.BuyersStory/delete");
    });

    //设计理念管理
    Route::group('DesignConcept', function () use ($version) {
        Route::get('index', "backend/{$version}.DesignConcept/index");
        Route::post('create', "backend/{$version}.DesignConcept/create");
        Route::post('update', "backend/{$version}.DesignConcept/update");
        Route::delete('delete', "backend/{$version}.DesignConcept/delete");
    });

})->allowCrossDomain([
    'Access-Control-Allow-Origin' => '*',
    'Access-Control-Allow-Methods' => 'GET,POST,PUT,DELETE',
    'Access-Control-Allow-Headers' => 'content-type,token,version',
    'Access-Control-Allow-Credentials' => 'true'
]);